package com.example.the_breakfast_club;
import static org.junit.Assert.*;
import java.math.BigInteger; // Not sure if we need this.
import java.util.*;

import org.junit.Test;

public class TestItOut {
	
	@Test
	public void testSetAdmin(){
		private final DatabaseHandler db;
		String tomEmail = "tom@gmail.com";
		String password = "password";
		Boolean unlocked = false;
		String contactInfo = "Chelsea";
		Boolean notAdmin = false;
		User testUser = new User(tomEmail, password, unlocked, contactInfo, notAdmin);
		db.addUser(testUser);
		assertFalse(db.getUser(tomEmail).isAdmin());
		db.setAdmin(tomEmail);
		assertTrue(db.getUser(tomEmail).isAdmin());
	}
	
	@Test
	public void testDeleteUser(){
		private final DatabaseHandler db;
		String tomEmail = "tom@gmail.com";
		String password = "password";
		Boolean unlocked = false;
		String contactInfo = "Chelsea";
		Boolean notAdmin = false;
		User testUser = new User (tomEmail, password, unlocked, 			contactInfo, notAdmin);
		db.addUser(testUser);
		assertTrue(db.accountExist(tomEmail));
		db.deleteUser(testUser);
		assertFalse(db.accountExist(tomEmail));

	}
	
	@Test
	public void testCheckForMatch(){
		private DatabaseHandler db; 
		Item a = new Item("Photo album", "contains pictures of family", "Atlanta, GA", 1, true, false);
		Item b = new Item("Photo album", "has pictures of my family", "Atlanta, GA", 1, false, false);
		db.addItem(a);
		db.addItem(b);
		//here they should be compared and resolved variables set to true, and names changed
		List<Item> bothItems = db.getAllItems();
		assertTrue(bothItems.get(0).getResolved());
		assertTrue(bothItems.get(1).getResolved());
	}

	@Test
	public void testCheckForMatch2(){
		private DatabaseHandler db; 
		Item a = new Item("Photo album", "contains pictures of family", "Baltimore, MD", 1, true, false);
		Item b = new Item("Photo album", "has pictures of my family", "Atlanta, GA", 1, false, false);
		db.addItem(a);
		db.addItem(b);
		//since the two items have different locations, their resolved variables will be false
		List<Item> bothItems = db.getAllItems();
		assertFalse(bothItems.get(0).getResolved());
		assertFalse(bothItems.get(1).getResolved());
	}

	@Test
	public void testLockUser(){
		private DatabaseHandler db;
		User peter = new User("Peter Polack", "qwerty", false, "@gmail.com", false);
		boolean isLocked = peter.getLockStatus();
		assertFalse(isLocked);
		db.lockUser(peter.getName()); //check this.
		isLocked = peter.getLockStatus();
		assertTrue(isLocked);
	}

	
}

